# dify/test.py

from dify.api import run_workflow, parse_workflow_response, DifyAPIError

def test_workflow():
    """测试工作流API调用"""
    
    # 测试产业报告工作流
    try:
        print("测试产业报告工作流...")
        response = run_workflow(
            workflow_name="产业报告",
            inputs={"context": "人工智能产业，最近一个月，创新风格"},
            user="49",
            response_mode="blocking"
        )
        
        print("\n=== 原始响应 ===")
        print(response)
        
        print("\n=== 解析后的文本 ===")
        text = parse_workflow_response(response)
        print(text)
        
    except (ValueError, DifyAPIError) as e:
        print(f"产业报告测试失败: {str(e)}")
    
    # 测试阶段总结工作流
    try:
        print("\n测试阶段总结工作流...")
        response = run_workflow(
            workflow_name="阶段总结",
            inputs={"context": "2023年第四季度人工智能领域技术进展"},
            user="49",
            response_mode="blocking"
        )
        
        print("\n=== 原始响应 ===")
        print(response)
        
        print("\n=== 解析后的文本 ===")
        text = parse_workflow_response(response)
        print(text)
        
    except (ValueError, DifyAPIError) as e:
        print(f"阶段总结测试失败: {str(e)}")

if __name__ == "__main__":
    test_workflow() 